package com.sino.cloud.api.domain;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;

public class License implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final Map<String, Object> vendorExtensions = new HashMap<String, Object>();
	private String name;
	private String url;

	public License name(String name) {
		setName(name);
		return this;
	}

	public License url(String url) {
		setUrl(url);
		return this;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@JsonAnyGetter
	public Map<String, Object> getVendorExtensions() {
		return vendorExtensions;
	}

	@JsonAnySetter
	public void setVendorExtension(String name, Object value) {
		if (name.startsWith("x-")) {
			vendorExtensions.put(name, value);
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((url == null) ? 0 : url.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		License other = (License) obj;
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		if (url == null) {
			if (other.url != null) {
				return false;
			}
		} else if (!url.equals(other.url)) {
			return false;
		}
		return true;
	}
}